#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;

const int maxn = 1100;
int f[maxn][maxn];
char s1[maxn], s2[maxn];

int main()
{
	while (scanf("%s%s", s1 + 1, s2 + 1) != EOF)
	{
		int n = strlen(s1 + 1);
		int m = strlen(s2 + 1);
		memset(f, 0, sizeof(f));
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++)
				if (s1[i] == s2[j])
					f[i][j] = f[i - 1][j - 1] + 1;
				else
					f[i][j] = max(f[i - 1][j], f[i][j - 1]);
		cout << f[n][m] << endl;
	}
	return 0;
}

